import React, { useEffect, useState } from "react";
import "./index.less";
import { NavBar, Tabs, Badge, Toast } from "antd-mobile";
import { Spin } from "antd";
import { PageHeader } from "@/components";
import { useNavigate, useLocation } from "react-router-dom";
import { getCurrentUser } from "@/utils/authority";
import { residentCouncilHall } from "./service";
type serviceListType = {
  id: number;
  name: string;
  url: string;
  img: any;
};
const ActivityOrTraining: React.FC = () => {
  const navigate = useNavigate();
  const location = useLocation();
  const [itemList, setItemList] = useState([])
  const goto = (url: string) => () => {
    navigate(url);
  }

  useEffect(() => {
    residentCouncilHall({ villageCode: "511602006004",/* classType:selectType  */ })
      .then((res) => {
        if (res.code == 200) {
          setItemList(res.data)
        }
      })
      .catch((error) => {
        console.log(error);
      });
  }, [])
  return (
    <div className="ActivityOrTraining_contarnier">
      <div className="header-bg">
        <NavBar
          onBack={() => navigate(-1)}
        >
          <div className="commontitle">居民议事厅</div>
        </NavBar>
      </div>
      <div className="ActivityOrTraining-content">
        {
          itemList?.map((item, index) => {
            return <div key={index} className="content_Item"
              onClick={goto(`/intelligentGovernance/theTownHall/proceedingsDetails?type=${"proceedingsDetails"}&&detail=${item?.id}`)}
            >
              <div className="toNewPage"
              >{item?.state==1?"去投票":"去参与"}</div>
              <img
                src={item?.img || "/images/mycommunity/noImage.jpg"} className="cover_img"></img>
              <div className="detail_box">
                <div className="detail_box-top">{item?.topic}</div>
                <div className="detail_box-center">{item?.address}</div>
                <div className="detail_box-bottom">
                  <div className="detail_box-bottom-type">{item?.topicType}</div>
                  <div className="detail_box-bottom-time">参与人数：<span>{item?.pointnum}</span></div>
                </div>
              </div>
            </div>
          })
        }
      </div>
    </div>
  );
};

export default ActivityOrTraining;
